<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>康纳天花系统后台</title>
<link href="/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="/css/admins/base.css" rel="stylesheet" type="text/css">
<link href="/css/plugs/jDatepicker/jDatepicker-min.css"  rel="stylesheet"  /> 
<script src="/js/plugs/jquery.js"></script>

<script src="/js/admins/base.js"></script>
<script src="/js/plugs/jDatepicker/jDatepicker-min.js"></script>
<script src="/js/plugs/global.js"></script>
<script src="/js/admins/salesman_manage.js"></script>
    <script src="/js/plugs/ymlayer.min.js"></script>
<style type="text/css" >
    {#$pageCss#}
</style>
</head>

<body>

<!-- nav start-->
{# include file="$tpl_root_path/admins/base/navbar.html" #}
<!-- nav end -->    
    
    
    
    
<div class="container-fluid">
    
      <div class="row">
      
    <!-- left  box start-->     
       {# include file="$tpl_root_path/admins/base/left_menu.html" #}
    <!-- left  box end-->        
 
  <!-- right  box start-->  
         
     <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main right-box">
          
          <div class="menu-navbar">{#$menu_navbar#}</div>
          <h3 class="page-header">业务人员管理 </h3>

          <div class="search-box">
              <form class="form-inline">
                <div class="form-group">
                  <label>添加时间:&nbsp;</label>
                  <div class="input-right-gicos">
                    <span class="ico input-ico-calendar"></span>
                    <input class="form-control" readonly="readonly" id="start_datepicker"   placeholder="开始时间" value="{#$start|date_format:'%Y-%m-%d'#}" type="text">
                 </div>
                </div>
                
                <div class="form-group">
                  <label>&nbsp;至&nbsp;</label>
                  <div class="input-right-gicos">
                    <span class="ico input-ico-calendar"></span>
                    <input class="form-control" readonly="readonly" id="end_datepicker"   placeholder="结束时间" value="{#$end|date_format:'%Y-%m-%d'#}" type="text" >
                 </div>
                </div>
                
                
                <div class="form-group">
                  <label>&nbsp;状态:&nbsp;</label>
                  <select class="form-select" id="state">
                    <option selected="" value="">请选择</option>
                   <option value="1" {#if $type=='pass'#}selected="selected"{#/if#}> 正常 </option>
                    <option value="0" {#if $type=='no_pass'#}selected="selected"{#/if#}>已注销</option>
                  </select>
                </div>
                
             
                 <div class="form-group">
                  <label>&nbsp;关键字:&nbsp;</label>
                  <input id="kw"  class="form-control"    placeholder="请输入姓名/邀请码/手机号码查询" value="{#if $kw#}{#$kw#}{#/if#}"    type="text" size="50"  onkeyup = "ValidateValue(this)">
                     &nbsp;
                     <a  class="btn btn-success" href="javascript:void(0)"  onclick = "searchsaleman()"  id="">查  询</a>

                </div>
          
                <!--<div class="submit-box">-->
                   <!--<button type="submit" class="btn btn-success">查&nbsp;询</button>-->
                <!--</div>-->
              </form>
          </div>
          
          <div class="tool-list-box">
              <a href="/admins/salesman_manage-cmd-add.html"  target="_blank" class="btn btn-warning">新增业务员</a>
          </div>
          
          <div class="info-list-box">
          <table class="table table-hover">
              <thead>
                <tr>
                  <!--<th>序号</th>-->
                  <th>姓名</th>
                  <th>邀请码</th>
                  <th>手机号码</th>
                  <th>联系电话</th>
                  <th>邮箱</th>
                  <th>添加时间</th>
                  <th>状态</th>
                  <th>操作</th>
                </tr>
              </thead>
              <tbody>

              {#if $classify_list#}
              {#foreach from=$classify_list item=i#}

                <tr>
                  <!--<th>{#$i.ID#}</th>-->
                  <td>{#$i.NAME#}</td>
                  <td>123456</td>
                  <td>{#$i.MOBILE#}</td>
                  <td>{#$i.TEL#}</td>
                  <td>{#$i.EMAIL#}</td>
                  <td>{#$i.DATELINE|date_format:'%Y-%m-%d %H:%M:%S'#}</td>
                  <td>{#if $i.CHECKSTATE==0#}已注销{#elseif $i.CHECKSTATE==1#}正常{#/if#}</td>
                  <td>
                      <a href="http://system.gzcanr.com/admins/salesman_manage-cmd-add-id-{#$i.ID#}.html" target="_blank">查看</a>&nbsp;
                      {#if $i.CHECKSTATE==1#}
                        <a href="#" onclick="cancal({#$i.ID#})">注销</a></td>

                      {#/if#}
                </tr>

              {#/foreach#}
              {#else#}
              <tr class="tab_list_tr">
                  <td colSpan="7" style="text-align:center;">
                      {#$nodatainfo#}
                  </td>
              </tr>
              {#/if#}

                
              </tbody>
            </table>
          </div>

         <div  id="pages">
             {#$pageform#}
         </div>

          
     </div>
 
  <!-- right  box end-->         
        
      </div>
</div>



</body>
</html>

<script type="text/javascript">

    //查询输入框不能输入特殊字符
    function ValidateValue(textbox)
    {
        var IllegalString = "\`~@#;,.!#$%^&*()+{}|\\:\"<>?-=/,\'";
        var textboxvalue = textbox.value;
        var index = textboxvalue.length - 1;

        var s = textbox.value.charAt(index);

        if(IllegalString.indexOf(s)>=0)
        {
            s = textboxvalue.substring(0,index);
            textbox.value = s;
        }
    }



//注销
    function cancal(id){

        var id =id;

        if (typeof id == 'undefined'){
            return false;
        }

        if(confirm('您确定要注销？')){
			
			     $.ajax({
                        type:"POST",
                        url:"http://system.gzcanr.com/admins/salesman_manage-cmd-cancal.html",
                        data:{'id':id},
                        //dataType:"json",
                        success:function(data){
                            if (data == 1) {
                                gMember.checkbox();
                                ymlayer.msg('注销成功！',1,9);
                                document.location.reload();
                            }else if(data == 2){
                                ymlayer.msg('注销失败！',1,9);
                            }else {
                                ymlayer.msg('注销失败！',1);
                            }
                        }
                    });
		}

    }

    //查询
    function searchsaleman(){
    //获取关键字
        var kw='';
        var key=$('#kw').val();
        kw=key;

   //获取状态
        var checkstate='';
        var options=$("#state option:selected");  //获取选中的项
        if(options.val()==0 &&  options.text()=='已注销'){
            checkstate='no_pass';
        }
        if(options.val()==1  ){
            checkstate='pass';
        }

        //获取时间
        var start_datepicker='';
        var end_datepicker='';
        var  start=Date.parse($('#start_datepicker').val());
        var  end=Date.parse($('#end_datepicker').val());

        if( isNaN(start )){
            start_datepicker='';

        }else {
            start_datepicker=start;
        }


        if( isNaN(end )){
            end_datepicker='';

        }else {
            end_datepicker=end;
        }

        //点击查询，必须要输入查询条件

//        alert('关键字'+kw);
//        alert(options.text());
//        alert('开始时间'+isNaN(start));
//        alert('结束时间'+isNaN(end));

        if(kw==''&&options.text()=='请选择'&&isNaN(start)&&isNaN(end)){
            alert('请输入查询条件');
            return false;
        }

        //若选择时间 ，则开始、结束都必须选

        if( !isNaN(end )&&  isNaN(start ) ){
            alert('请选择开始时间');
            $('#start_datepicker').focus();
            return false;
        }

        if( !isNaN(start )&&  isNaN(end ) ){
            alert('请选择结束时间');
            $('#end_datepicker').focus();
            return false;
        }


        //截止时间要大于开始时间
        if(end <start){
           alert('截止时间要大于开始时间');
            $('#end_datepicker').focus();
            return false;
        }



        window.location.href='http://system.gzcanr.com/admins/salesman_manage-kw-'+kw+'-type-'+checkstate+'-start-'+start_datepicker+'-end-'+end_datepicker+'.html'




    }


</script>